package com.unicdata.ai.demo_2af.service.impl;

/**
 * @author lhn
 * @date 2025/06/25 16:59
 * @since 1.0.0
 **/

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.unicdata.ai.demo_2af.common.entity.Permission;
import com.unicdata.ai.demo_2af.mapper.PermissionMapper;
import com.unicdata.ai.demo_2af.service.PermissionService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * 权限服务实现类
 *
 * @author java-engineer
 */
@Service
public class PermissionServiceImpl extends ServiceImpl <PermissionMapper, Permission> implements PermissionService {

    @Override
    public Permission getPermissionByCode(String permissionCode) {
        if (StringUtils.isBlank(permissionCode)) {
            return null;
        }

        LambdaQueryWrapper<Permission> queryWrapper = new LambdaQueryWrapper <>();
        queryWrapper.eq(Permission::getPermissionCode, permissionCode);
        return baseMapper.selectOne(queryWrapper);
    }
}